package com.test39_集合应用;

import com.test39_集合应用.factory.ServiceFactory;
import com.test39_集合应用.service.IStudentService;
import com.test39_集合应用.vo.Student;
import org.junit.Test;

import java.util.Collections;
import java.util.List;

/**
 * 学生成绩统计
 */
public class YootkDemo_03 {

    @Test
    public void test1() {
        IStudentService studentService = ServiceFactory.getStudentServiceInstance();
        studentService.add(new Student("张三", 18, 78.9, 89.2, 91.3));
        studentService.add(new Student("李四", 19, 65.2, 39.2, 89.5));
        studentService.add(new Student("王五", 17, 89.8, 78.5, 93.3));
        System.out.println("------------------- 【1】每位学生的总成绩 -------------------");
        System.out.println(studentService.getAllScore());
        System.out.println("------------------- 【2】每门课程的平均成绩 -------------------");
        System.out.println(studentService.getAvgScore());
        System.out.println("------------------- 【3】学习成绩大排名 -------------------");
        List<Student> all = studentService.findAll();
        Collections.sort(all);  // 数据排序
        all.forEach(System.out::println);
    }
}
